namespace EAL.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "Options",
                c => new
                    {
                        MachineName = c.String(nullable: false, maxLength: 4000),
                        LicenseAccepted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.MachineName);
            
            CreateTable(
                "Orders",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CreationTime = c.DateTime(nullable: false),
                        State = c.String(maxLength: 4000),
                        Customer_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("Customers", t => t.Customer_Id)
                .Index(t => t.Customer_Id);
            
            CreateTable(
                "Customers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Address = c.String(maxLength: 4000),
                        FirstName = c.String(maxLength: 4000),
                        LastName = c.String(maxLength: 4000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "Positions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Product_Id = c.Int(),
                        Order_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("Products", t => t.Product_Id)
                .ForeignKey("Orders", t => t.Order_Id)
                .Index(t => t.Product_Id)
                .Index(t => t.Order_Id);
            
            CreateTable(
                "Products",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 4000),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        Stock = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "Addresses",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Street = c.String(maxLength: 4000),
                        City = c.String(maxLength: 4000),
                        Country = c.String(maxLength: 4000),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("Positions", new[] { "Order_Id" });
            DropIndex("Positions", new[] { "Product_Id" });
            DropIndex("Orders", new[] { "Customer_Id" });
            DropForeignKey("Positions", "Order_Id", "Orders");
            DropForeignKey("Positions", "Product_Id", "Products");
            DropForeignKey("Orders", "Customer_Id", "Customers");
            DropTable("Addresses");
            DropTable("Products");
            DropTable("Positions");
            DropTable("Customers");
            DropTable("Orders");
            DropTable("Options");
        }
    }
}
